package com.eastmoney.emis.edda.infrastructure.constraint.service;

import com.eastmoney.emis.edda.domain.valueobject.TimeFormatter;
import com.eastmoney.emis.edda.infrastructure.constraint.repository.BusinessDayRepository;
import com.eastmoney.emis.utils.common.po.BaseResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

/**
 * @description: Description
 * @projectName: EDDA-HSBC
 * @package: com.eastmoney.emis.edda.infrastructure.constraint.service
 * @author: 汪程程
 * @date: 2022/10/15 1:11 PM
 * @version: 1.0
 */
@Service
public class BusinessDayService {

    @Autowired
    private BusinessDayRepository repository;

    public boolean isBusinessDayOfToday() {
        String dayStr = LocalDateTime.now().format(TimeFormatter.YYYYMMDD);
        BaseResponse<Boolean> resp = repository.isHKBusinessDay(dayStr);
        return resp.getStatus() == 0 && resp.getData() != null && resp.getData();
    }
}
